/**
 * 认证模块相关类型定义
 */

// 登录请求参数
export interface LoginRequest {
  username: string
  password: string
  remember?: boolean
}

// 注册请求参数
export interface RegisterRequest {
  username: string
  password: string
  email: string
  code?: string
  confirmPassword?: string
  agreement?: boolean
}

// 用户信息
export interface UserInfo {
  id: number | string
  username: string
  email: string
  avatar?: string
  avatarUrl?: string
  nickname?: string
  phone?: string
  role: string
  createdAt?: string
  updatedAt?: string
}

// API响应基础接口
export interface ApiResponse<T> {
  success: boolean
  message: string
  data: T
}

// 登录响应
export interface LoginResponse extends ApiResponse<{
  token: string
  user: UserInfo
}> {}

// 注册响应
export interface RegisterResponse extends ApiResponse<{
  token: string
  user: UserInfo
}> {}

// 用户信息响应
export interface UserInfoResponse extends ApiResponse<UserInfo> {}

// 重置密码请求
export interface ResetPasswordRequest {
  email: string
  code: string
  password: string
}

// 重置邮件请求
export interface ResetEmailRequest {
  email: string
}

// 认证状态
export interface AuthState {
  token: string | null
  refreshToken: string | null
  user: UserInfo | null
  isAuthenticated: boolean
  expiresAt: number | null
}

// 刷新令牌响应
export interface RefreshTokenResponse {
  token: string
  refreshToken: string
  expiresIn: number
}

// 通用认证响应
export interface AuthResponse {
  code: number
  message: string
  data: {
    token: string
    openid?: string | null
    username?: string
    email?: string
    avatar?: string
    avatarUrl?: string | null
    nickname?: string | null
    phone?: string | null
    role?: string
    newUser?: boolean
    createdAt?: string
    updatedAt?: string
  }
} 